<script setup lang="ts">
import router from '@/router'
import { useRoute } from 'vue-router'
import { reactive } from 'vue'
import type {
  SongCommentObj,
  SongRepayObj

} from '@/types/Playing'
const route = useRoute()
const commentObj: SongCommentObj = JSON.parse(route.query.comment as string)
// 路由参数query并不是ref响应式数据，需要转换一下ref,跟reactive都可以
//const comment = ref<SongCommentObj>(commentObj)
const comment = reactive(commentObj)
const onUser = (repay:SongRepayObj)=>{
  console.log('跳转到这个人【' + repay.name + '】的详情')
}
const onTopic = (repay:SongRepayObj)=>{
  console.log(repay.id)
  console.log('这里没有做repay的话题[],所以跳转到评论的话题算了,跳转到话题>>>' + comment.topic![0])
}
const onZan = (repay:SongRepayObj)=>{
  console.log('这里没有做是否赞过的功能，就让他一直加算了>>>>')
  repay.zanCount ++
  console.log(repay.zanCount)
}
const onRepay = (repay:SongRepayObj)=>{
  console.log('回复这个replay 【' + repay.content + '】')
}
</script>

<template>
  <div class="header">
    <span class="iconfont icon-angle-up-l icon-more" @click="router.go(-1)"></span>
    <span class="title">
      {{ comment.repays!.length }}条回复
    </span>
  </div>
  <div class="content">
    <div class="cell" v-for="repay in comment.repays" :key="repay.id">
      <div class="cell-avater" :style="{backgroundImage : `url(${comment.avater})`}" @click="onUser(repay)" >

      </div>
      <div class="cell-content">
        <div class="name" @click="onUser(repay)">
            {{ repay.name }}
        </div>
        <div class="time">
          {{ repay.time }}
        </div>
        <div class="comment" @click="onRepay(repay)">
          {{ repay.content }}
        </div>
        <div class="topic" v-if="comment.topic" @click="onTopic(repay)">
          # {{ comment.topic![0] }}
        </div>
      </div>
      <div class="cell-zan" @click="onZan(repay)">
        <span class="iconfont icon-zan icon"></span>
        <span class="cell-zan-count">{{ repay.zanCount }}</span>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.header {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  background-color: #000;
  width: 100%;
  height: 10vh;
}

.title {
  font-size: 6vw;
  line-height: 10vw;
  color: white;
  background-color: transparent;
  position: absolute;
  bottom: 0;
  text-align: center;
  width: 100%;
}

.icon-more {
  font-size: 6vw;
  line-height: 10vw;
  color: white;
  background-color: transparent;
  position: absolute;
  bottom: 0;
  left: 4vw;
  z-index: 66;
}

.content {
  padding: 10vh 4vw 0 4vw;
  background-color: transparent;
}

.cell {
  display: flex;
  padding-bottom: 4vw;
  background-color: transparent;
}

.cell-avater {
  background-color: transparent;
  width: 10vw;
  height: 10vw;
  border-radius: 50%;
  background-size: cover;
}

.cell-content {
  flex: 1;
  padding: 0 4vw 0vw 2vw;
  background-color: transparent;
}

.cell-zan {
  background-color: transparent;
  width: 10vw;
  height: 10vw;
}
.icon {
  display: block;
  color: #fff;
  font-size: 4vw;
  background-color: transparent;
  text-align: center;
}
.cell-zan-count {
  display: block;
  color: #fff;
  font-size: 4vw;
  background-color: transparent;
  text-align: center;
}
.name {
  color: #fff;
  font-size: 4vw;
  line-height: 6vw;
  background-color: transparent;
}
.time {
  color: #fff;
  font-size: 3vw;
  line-height: 4vw;
  background-color: transparent;
}

.comment {
  color: #fff;
  font-size: 4vw;
  background-color: transparent;
  padding-top: 3vw;
}

.topic {
  display: inline-block;
  font-size: 3.5vw;
  color: #fff;
  background-color: #666;
  margin-top: 3vw;
  padding: 1vw 2vw;
  border-radius: 3vw;
  
}
</style>